2018/7/21

Course project

Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!

Motor Trend

We are particularly interested in the following two questions:

  • “Is an automatic or manual transmission better for MPG”
  • "Quantify the MPG difference between automatic and manual transmissions"

Calculate correlation

wt, disp and cyl show high correlation.

kable( cor( mtcars[, c(1, 9, 6, 3, 2)]), digits = 2)
mpg am wt disp cyl
mpg 1.00 0.60 -0.87 -0.85 -0.85
am 0.60 1.00 -0.69 -0.59 -0.52
wt -0.87 -0.69 1.00 0.89 0.78
disp -0.85 -0.59 0.89 1.00 0.90
cyl -0.85 -0.52 0.78 0.90 1.00

Summary

betterFit <- lm(mpg ~ am + wt + disp + cyl, mtcars)
summary(betterFit)
## 
## Call:
## lm(formula = mpg ~ am + wt + disp + cyl, data = mtcars)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.318 -1.362 -0.479  1.354  6.059 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 40.898313   3.601540  11.356 8.68e-12 ***
## am           0.129066   1.321512   0.098  0.92292    
## wt          -3.583425   1.186504  -3.020  0.00547 ** 
## disp         0.007404   0.012081   0.613  0.54509    
## cyl         -1.784173   0.618192  -2.886  0.00758 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.642 on 27 degrees of freedom
## Multiple R-squared:  0.8327, Adjusted R-squared:  0.8079 
## F-statistic: 33.59 on 4 and 27 DF,  p-value: 4.038e-10

Residuals vs Leverage

Thank you!